<include file="Common:header" />
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 修改角色
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <div class="result_title">
            <h3>修改角色</h3>
            <notempty name='Think.get.msg'>
                <div class="mark">
                    <p>{$Think.get.msg}</p>
                </div>
            </notempty>
        </div>
    </div>

    <!--结果集标题与导航组件 结束-->

    <div class="result_wrap">
        <form id="editRole_form" method="post">
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th><i class="require">*</i>角色名称：</th>
                        <td>
                            <input type="text" id="name" name="name" value="{$role.name}">
                        </td>
                    </tr>
                    <tr>
                        <th>角色描述：</th>
                        <td>
                            <input type="text" name="remark" id="remark" value="{$role.remark}" >
                        </td>
                    </tr>
                    <tr>
                        <th>是否开启：</th>
                        <td>
                            <label for=""><input type="radio" name="status" value="1" <if condition="$role['status']">checked="checked"</if> />开启</label>
                            <label for=""><input type="radio" name="status" value="0" <if condition="$role['status']==0">checked="checked"</if>/>关闭</label>
                        </td>
                    </tr>
                    <tr>
                        <th>排序：</th>
                        <td>
                            <input type="text" class="sm" name="sort" value="{$role.sort}" >
                        </td>
                    </tr>
                    <tr>
                        <th></th>
                        <td>
                            <input type="hidden" name="id" value="{$role.id}" />
                            <input type="submit" id="button" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>

</body>
</html>

<script type="text/javascript">
    $(function() {
        $("#button").click(function() {
            var name = $("#name").val();
            var remark = $("#remark").val();
            if(name == ''){
                layer.msg('角色名称不能为空！');
                $("#name").focus();
                return false;
            }
            if(remark == ''){
                layer.msg('角色描述不能为空！');
                $("#remark").focus();
                return false;
            }
            $.post("{:U(MODULE_NAME.'/Access/editRole')}", $("#editRole_form").serialize(),function(data) {
                if (data.status == 1) {
                    layer.alert(data.msg, {icon: 6});
                    $('.layui-layer-btn .layui-layer-btn0').click(function(){
                        location.href="{:U(MODULE_NAME.'/Access/role')}";
                    });
                }else {
                    layer.alert(data.msg, {icon: 5});
                }
            });
        });
    })
</script>